#include <iostream>
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <ctype.h>

using namespace std;

//#define mydebug 

typedef struct BSTNode {
	char buf[10];
	int num;
	BSTNode* left, *right;	
	BSTNode() {
		num = 0;
		left = right = NULL;
	}
}*BSTree;


int insertBST(BSTree& t, char* str);
void inorderBST(BSTree t);

int main () {
	int n,i,j;
	int count = 0;
	char str[10];
	char ch;
	BSTree t = NULL;	 
	scanf("%d", &n);
	assert( n > 0);
	getchar();
	for(i = 0; i < n; i++){
		j = 0;
		while((ch=getchar())!= '\n'){
			if(j == 3){
				str[j++] = '-';	
			}
			if(ch == '-')
				continue;
			else {
				if (isupper(ch)){
					switch (ch){
						case 'A':case 'B':case 'C':
							ch = '2';
							break;
						case 'D':case 'E':case 'F':
							ch = '3';
							break;
						case 'G':case 'H':case 'I':
							ch = '4';
							break;
						case 'J':case 'K':case 'L':
							ch = '5';
							break;
						case 'M':case 'N':case 'O':
							ch = '6';
							break;
						case 'P':case 'R':case 'S':
							ch = '7';
							break;
						case 'T':case 'U':case 'V':
							ch = '8';
							break;
						case 'W':case 'X':case 'Y':
							ch = '9';
							break;
					}
				}
				str[j++]= ch;
			}
		}
		str[j++]='\0';
		assert(j ==9);
//                mydebug("insert string %s \n", str);
		int r = insertBST(t, str);
		count += r;
	}
	if(count == 0)
		printf("No duplicates.\n");
	else{
		inorderBST(t);
	}

	return 0;
}



int insertBST(BSTree& t, char* str){
	BSTree p, l;
	l = NULL;
	p = t;
	int sr = 0;
	while(p != NULL){
		sr = strcmp( str, p->buf);
		if( sr == 0){
			p->num++;
//                        mydebug("str %s has the num %d \n", str, p->num);
			break;
		}
		l = p;
		p = (sr < 0)? p->left: p->right;
	}
	if(p == NULL){
		p = new BSTNode();
		strcpy(p->buf, str);
		if(l == NULL){ // the tree is null tree
			t = p;
		}else {
			if(sr <0){
				l->left = p;
			} else if(sr >0){
				l->right = p;
			}else{
				//do nothing
			}
		}
	}
	return p->num;	
}


void inorderBST(BSTree t){
	BSTree p = t;
	if(p == NULL)
		return;
	inorderBST(p->left);
	if(p->num > 0){
		printf("%s %d\n", p->buf, p->num+1);
	}
//        mydebug("inorder with node %s \n", p->buf);
	inorderBST(p->right);	
}


